package tn.orange.canreminder.service;

import java.util.List;

import org.apache.http.NameValuePair;

import tn.orange.canreminder.conf.Config;
import tn.orange.canreminder.model.Competition;
import tn.orange.canreminder.model.JSONCompetitions;
import tn.orange.canreminder.model.JSONPhases;
import tn.orange.canreminder.model.JSONPoules;
import tn.orange.canreminder.model.Phase;
import tn.orange.canreminder.model.Poule;
import tn.orange.canreminder.parse.GenericJsonParser;

public class CompetitionServiceImp implements CompetitionService {

	GenericJsonParser parser = new GenericJsonParser();

	@Override
	public List<Competition> getAllCompetition(
			List<NameValuePair> nameValuePairs) throws Exception {
		parser.setOutput(JSONCompetitions.class);
		parser.setUrl(Config.competitions);
		parser.setNameValuePairs(nameValuePairs);
		JSONCompetitions competitions = (JSONCompetitions) parser.parse();
		return competitions.getCompetitions();
	}

	@Override
	public List<Poule> getAllPoules(List<NameValuePair> nameValuePairs)
			throws Exception {
		// TODO Auto-generated method stub
		parser.setOutput(JSONPoules.class);
		parser.setUrl(Config.poules);
		parser.setNameValuePairs(nameValuePairs);
		JSONPoules poules = (JSONPoules) parser.parse();
		return poules.getPoules();
	}

	@Override
	public List<Phase> getAllPhases(List<NameValuePair> nameValuePairs) throws Exception {
		// TODO Auto-generated method stub
		parser.setOutput(JSONPhases.class);
		parser.setUrl(Config.phases);
		parser.setNameValuePairs(nameValuePairs);
		JSONPhases jsonPhases = (JSONPhases) parser.parse();
		return jsonPhases.getPhases();
	}
}
